﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;

namespace lottery
{
    //写文件有点问题
    public partial class Form2 : Form
    {
        string iniFile = Application.StartupPath + @"\license.lic";
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string corpName = textBox1.Text;
            string ctlCode = textBox2.Text;
            
            if (!CheckCode.check(corpName, ctlCode))
            {
                MessageBox.Show("错误的操作码，请联系惠州挨踢致富群 扎俊tlls或423062699@qq.cm");
            }
            else {
                
                string defaultIni = @"
CorpName=" + corpName + @"
Sn=" + ctlCode + @"
";
                
                File.WriteAllText(iniFile, defaultIni, Encoding.Default);
                MessageBox.Show("操作码验证成功,请重启程序。");
                this.Hide();

            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            if (File.Exists(iniFile))
            {
                CheckCode ck = new CheckCode();
                textBox1.Text = ck.get("CorpName");
                textBox2.Text = ck.get("Sn");
               

            }
           
        }
    }
}
